package com.kgis.kp.jdbctemplate.core;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import oracle.jdbc.OracleConnection;

import org.springframework.jdbc.core.support.AbstractSqlTypeValue;

/**
 * 
 * @author zhxiaomiao
 * 
 */
public class OracleArrayValue extends AbstractSqlTypeValue {

	private List<?> values;

	public OracleArrayValue(List<?> values) {
		this.values = values;
	}

	public Object createTypeValue(Connection conn, int sqlType, String typeName) throws SQLException {
		OracleConnection oracleConn = (OracleConnection) conn;
		oracle.sql.ArrayDescriptor desc = oracle.sql.ArrayDescriptor.createDescriptor(typeName, oracleConn);
		return new oracle.sql.ARRAY(desc, oracleConn, values.toArray());
	}
}